home *** CD-ROM | disk | FTP | other *** search
/ Champak 29 / Volume 29 - JOGO DISK .iso / Games / jungle_adventure.swf / scripts / __Packages / GameContainer.as < prev    next >
Text File  |  2006-11-29  |  3KB  |  98 lines

  1. class GameContainer extends SSObject
  2. {
  3.    var classID = SSGlobal.CLSID_CONTAINER;
  4.    var collisionMask = SSGlobal.CLSID_SHAPE | SSGlobal.CLSID_MOBILEOBJECT | SSGlobal.CLSID_OBJECT;
  5.    var assetID = "Vase";
  6.    var beingCarried = false;
  7.    var editor_isItem = true;
  8.    var editor_name = "Vase";
  9.    var editor_args_names = ["contents"];
  10.    var editor_args_values = [GameContainer.prototype.contents == null ? "" : GameContainer.prototype.contents];
  11.    var editor_args_types = ["string"];
  12.    var editor_args_options = ["A-Za-z"];
  13.    var editor_args_descriptions = [""];
  14.    var editor_args_mode = [0];
  15.    var editor_args_component = ["TextInput"];
  16.    function GameContainer(contents)
  17.    {
  18.       super();
  19.       this.contents = contents;
  20.    }
  21.    function onCollision(obj)
  22.    {
  23.       if(obj.classID == SSGlobal.CLSID_VEHICLE)
  24.       {
  25.          this.shatter();
  26.          return undefined;
  27.       }
  28.       if(this.beingCarried)
  29.       {
  30.          return undefined;
  31.       }
  32.       obj.lastContainer = this;
  33.    }
  34.    function updatePosition(elapsed)
  35.    {
  36.       var _loc3_ = this.x;
  37.       var _loc2_ = this.y;
  38.       this.velocity.y += SSGlobal.GRAVITY * elapsed;
  39.       this.checkCollisions(elapsed);
  40.       this.moveBy(this.velocity.x * this.motionTime,this.velocity.y * this.motionTime,0);
  41.       if(Math.abs(_loc3_ - this.x) < 0.5 && Math.abs(_loc2_ - this.y) < 0.5)
  42.       {
  43.          this.x = _loc3_;
  44.          this.y = _loc2_;
  45.          if((this.inMotion -= elapsed) <= 0)
  46.          {
  47.             this.cancelUpdates();
  48.             this.velocity.loc(0,0,0);
  49.          }
  50.       }
  51.    }
  52.    function checkCollision(obj)
  53.    {
  54.       if(!obj.inScene)
  55.       {
  56.          return undefined;
  57.       }
  58.       var _loc3_ = undefined;
  59.       if((obj.classID & 4294901760) !== SSGlobal.CLSID_SHAPE)
  60.       {
  61.          if(SSCollision.sweepSphereToSphere(this,obj,true))
  62.          {
  63.             this.shatter(obj);
  64.             obj.immobilize();
  65.          }
  66.       }
  67.       else if(_loc3_ = SSCollision.sweepSphereToStaticShape(this,obj))
  68.       {
  69.          this.shatter();
  70.       }
  71.    }
  72.    function shatter()
  73.    {
  74.       GameSound.playSound("shatter");
  75.       if(this.contents)
  76.       {
  77.          var _loc2_ = new this.contents();
  78.          _loc2_.x = this.x;
  79.          _loc2_.y = this.y;
  80.          this.world.addObject(_loc2_);
  81.          _loc2_.addToScene();
  82.       }
  83.       this.dropParticle("vase0",this.x,this.y,this.z,this.velocity.x - 100,-200,-350,-180,4);
  84.       this.dropParticle("vase1",this.x,this.y,this.z,this.velocity.x + 100,-200,-350,180,4);
  85.       this.dropParticle("vase2",this.x,this.y,this.z,this.velocity.x - 100,-100,-200,-180,4);
  86.       this.dropParticle("vase3",this.x,this.y,this.z,this.velocity.x + 100,-100,-200,180,4);
  87.       this.world.removeObject(this);
  88.    }
  89.    function dropParticle(asset, x, y, z, vx, vy, vz, r, t)
  90.    {
  91.       var _loc2_ = new SSParticle(asset,t,new Vector(vx,vy,vz),r,SSGlobal.GRAVITY);
  92.       _loc2_.x = x;
  93.       _loc2_.y = y;
  94.       _loc2_.z = z;
  95.       this.world.addObject(_loc2_);
  96.    }
  97. }
  98.